package com.lumacong.websocket.util;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CutPicUtil {

    /**
     * 19      * 屏幕截图
     * 20      * @param imageName 存储图片名称
     * 21      * @param path 图片路径
     * 22      * @param imgType 图片类型
     * 23      * @throws AWTException
     * 24      * @throws IOException
     * 25
     */
    public static void cutPic(String imageName, String path, String imgType) throws AWTException, IOException {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle screenRectangle = new Rectangle(screenSize);
        Robot robot = new Robot();
        BufferedImage image = robot.createScreenCapture(screenRectangle);
        ImageIO.write(image, imgType, new File(path + imageName + "." + imgType));
    }
}
